package com.example.handsets8app.Utils;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.handsets8app.R;

public class DialogTipShow {

    private static DialogTipShow instance;
    private AlertDialog dialog;

    public static synchronized DialogTipShow getInstance() {
        if (instance == null) {
            instance = new DialogTipShow();
        }
        return instance;
    }

    public void ShowDialog(Context context, String tip) {
        View view = LayoutInflater.from(context).inflate(R.layout.pop_check, null, false);
        dialog = new AlertDialog.Builder(context).setView(view).create();

        RelativeLayout rlError = (RelativeLayout) view.findViewById(R.id.rl_itme);
        TextView tvTip = (TextView) view.findViewById(R.id.pop_checked_tv_result);
        tvTip.setText(tip);
        rlError.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        dialog.getWindow().setLayout((ScreenUtils.getScreenWidth(context) / 4 * 3), LinearLayout.LayoutParams.WRAP_CONTENT);
    }

    public void ShowDialogSuccess(Context context, String tip) {
        View view = LayoutInflater.from(context).inflate(R.layout.pop_check_right, null, false);
        dialog = new AlertDialog.Builder(context).setView(view).create();

        RelativeLayout rlError = (RelativeLayout) view.findViewById(R.id.rl_itme);
        TextView tvTip = (TextView) view.findViewById(R.id.pop_checked_tv_result);
        tvTip.setText(tip);
        rlError.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        dialog.getWindow().setLayout((ScreenUtils.getScreenWidth(context) / 4 * 3), LinearLayout.LayoutParams.WRAP_CONTENT);
    }

    public void ShowDialogError(Context context, String tip) {
        View view = LayoutInflater.from(context).inflate(R.layout.pop_check, null, false);
        dialog = new AlertDialog.Builder(context).setView(view).create();

        RelativeLayout rlError = (RelativeLayout) view.findViewById(R.id.rl_itme);
        TextView tvTip = (TextView) view.findViewById(R.id.pop_checked_tv_result);
        tvTip.setText(tip);
        rlError.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        dialog.getWindow().setLayout((ScreenUtils.getScreenWidth(context) / 4 * 3), LinearLayout.LayoutParams.WRAP_CONTENT);
    }

}
